/* eslint-disable max-lines-per-function */
/* eslint-disable import/prefer-default-export */
import {Space, Button, Popconfirm} from 'antd';
import dayjs from 'dayjs';
import {Link} from 'umi';
import {EditOutlined, DeleteOutlined, SearchOutlined} from '@ant-design/icons';
import {thousandthNum, fen2yuan, ratio2percent} from '@/utils/utils';

const iconStyle = {
    padding: 0
};

export const getColumns = (sortInfo, filterInfo, tablefilters, handleEdit, handleDel) => [
    {
        title: '开课时间',
        key: 'beginTime',
        dataIndex: 'beginTime',
        render: value => dayjs(value).format('YYYY-MM-DD')
    },
    {
        title: '学部',
        key: 'departmentName',
        dataIndex: 'departmentName',
    },
    {
        title: '学科',
        key: 'subjectName',
        dataIndex: 'subjectName',
        filters: tablefilters?.subjectList || [],
        filteredValue: filterInfo.subject || null,
    },
    {
        title: '地区',
        key: 'area',
        dataIndex: 'area',
        filters: tablefilters?.areaList || [],
        filteredValue: filterInfo.area || null,
    },
    {
        title: '年级',
        key: 'gradeName',
        dataIndex: 'gradeName'
    },
    {
        title: '主讲老师',
        key: 'teacherName',
        dataIndex: 'teacherName'
    },
    {
        title: '班级ID',
        key: 'clazzBizNumber',
        dataIndex: 'clazzBizNumber'
    },
    {
        title: '班级名称',
        key: 'clazzName',
        dataIndex: 'clazzName'
    },
    {
        title: '辅导老师',
        key: 'assistantName',
        dataIndex: 'assistantName'
    },
    {
        title: '综合续班人数',
        key: 'complehensiveCount',
        dataIndex: 'complehensiveCount',
        sorter: true,
        sortOrder: sortInfo.columnKey === 'complehensiveCount' && sortInfo.order,
        render: number => thousandthNum(number),
    },
    {
        title: '综合续班金额',
        key: 'complehensivePrice',
        dataIndex: 'complehensivePrice',
        sorter: true,
        sortOrder: sortInfo.columnKey === 'complehensivePrice' && sortInfo.order,
        render: number => fen2yuan(number),
    },
    {
        title: '综合续班率',
        key: 'complehensiveRatio',
        dataIndex: 'complehensiveRatio',
        sorter: true,
        sortOrder: sortInfo.columnKey === 'complehensiveRatio' && sortInfo.order,
        render: number => ratio2percent(number)
    },
    {
        title: '操作',
        width: 120,
        fixed: 'right',
        render(record) {
            return (
                <Space size={10}>
                    <Button
                        type="link"
                        style={iconStyle}
                        onClick={() => handleEdit(record)}
                    >
                        <EditOutlined />
                    </Button>
                    <Link to={`/crud/edit/${record?.id}`}>
                        <SearchOutlined />
                    </Link>
                    <Popconfirm
                        title="确定删除么？"
                        onConfirm={() => handleDel(record?.id)}
                    >
                        <Button type="link" style={iconStyle}>
                            <DeleteOutlined />
                        </Button>
                    </Popconfirm>
                </Space>
            );
        }
    }
];

export const layout = {
    labelCol: {span: 4},
    wrapperCol: {span: 14},
};

export const facultyList = [
    {key: 10, value: '小学'},
    {key: 20, value: '初中'},
    {key: 30, value: '高中'}
];

export const activityTypeList = [
    {key: 23, value: '联报'},
    {key: 2, value: '单课'}
];

export const roleList = [
    {key: 2, value: '辅导'},
    {key: 3, value: '销售'}
];

